package com.demo.javaDemo.data;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class DefensiveCopy {

	public static void main(String[] args) {
		List<String> list=Arrays.asList("a","b","c");
		List<String> readonlyList=Collections.unmodifiableList(list);
		list.add("c");//java.lang.UnsupportedOperationException
		System.out.println(readonlyList.size());
		readonlyList.add("d");//java.lang.UnsupportedOperationException
	}

}
